<?php

require_once dirname(__FILE__).'/../lib/trainerGeneratorConfiguration.class.php';
require_once dirname(__FILE__).'/../lib/trainerGeneratorHelper.class.php';

/**
 * trainer actions.
 *
 * @package    sf_sandbox
 * @subpackage trainer
 * @author     Your name here
 * @version    SVN: $Id: actions.class.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
 */
class trainerActions extends autoTrainerActions
{
    public function executeNewPopup(sfWebRequest $request){
        $this->setLayout('popupLayout');
        
        $this->rel_input = $this->getRequestParameter('rel_input');
        $this->form = new TrainerForm();
        if($request->isMethod('POST')){
            $data = $this->getRequestParameter($this->form->getName());
            $this->form->bind($data);
            
            if($this->form->isValid()){
                $this->new_obj = $this->form->save();
                $this->saved_successfully = true;
            }
        }
    }
    
    public function executeAutocompleteName(sfWebRequest $request){
        //TODO: implement
        $q = $this->getRequestParameter('q');
        $data = TrainerTable::getInstance()->getAutocompleteData($q);
        
        return $this->renderText(json_encode($data));
    }
}
